<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /*
        理解：浅拷贝，只克隆第一层，修改拷贝后的第二层将影响被拷贝的数据
        */

        // 浅拷贝
        (function () {
            let obj = {
                a: 10,
                b: [10, 20],
                c: {
                    x: 10
                },
                d: /^d+$/
            }
            let obj1 = { ...obj }  //第一种
            let obj2 = Object.assign({}, obj)  //第二种
            //封装 第三种
            let obj3 = {}
            for (let key in obj) {
                if (!obj.hasOwnProperty((key))) break;
                obj3[key] = obj[key]
            }
        })()


    </script>
</body>

</html>